package com.LeeCode;

import java.util.HashSet;

/**
 * 与对应负数同时存在的最大正整数
 */

public class Code2441 {
    public static void main(String[] args) {
        int[] nums = {-10, 8, 6, 7, -2, -3};
        System.out.println(new Code2441().findMaxK(nums));
    }

    public int findMaxK(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        int ans = -1;
        for (int i = 0; i < nums.length; i++) {
            if(set.contains(-nums[i])) {
                ans = Math.max(ans, Math.abs(nums[i]));
            }
            set.add(nums[i]);
        }
        return ans;
    }
}
